<?php
// View for admin - articles
require_once WACT_ROOT.'controller/controller.inc.php';
require_once WACT_ROOT .'controller/form.inc.php';
require_once WACT_ROOT.'view/view.inc.php';
require_once WACT_ROOT .'view/formview.inc.php';

require_once APP_ROOT . 'view/common/layout.formview.php';
require_once APP_ROOT . 'view/common/layout.view.php';

require_once 'model/common/user.php';
require_once 'model/common/player.php';
require_once 'model/common/categories.php';
require_once 'model/common/date.php';


class PlayersListView extends LayoutFormView {

    function PlayersListView($TemplateFile) {
        parent :: LayoutFormView($TemplateFile);
    }

    function prepare(&$controller, &$request, &$responseModel) {
    	parent::prepare($controller, $request, $responseModel);
		        
		$this->Template->set('SITE_CSS',Site::getSiteTemplateCSS());
		$this->Template->set('SITE_BASE',Site::getSiteTemplateBase());
		$this->Template->set('SITE_TITLE',Site::getTitle());
		$this->Template->set('title',Site::getTitle().' - ');


        $pager =& $this->Template->getChild('pagenav');
        $pager2 =& $this->Template->getChild('pagenav2');
        $list =& Player::getNewPlayersList($pager,$request,$responseModel);
        $list->paginate($pager2);

        $list_updated=array();


        $list->reset();
        while ($list->next()) {

        	$dataspace = $list->export();
            $firstname = $list->get('firstname');
            $lastname = $list->get('lastname');
            $player_id = $list->get('player_id');
            $ds =& DataSpace::makeDataSpace($dataspace);
            //print_r(  $dataspace );
            $author_show = User::getFullUserName($ds);
            $dataspace['author_show'] =  $author_show;

            $category1 = $list->get('category1');
            $category2 = $list->get('category2');


            if ( $category2 && $category1 ) $category_show = $category1.'-'.$category2;
            else if (  $category2 ) $category_show = $category2;
            else if (  $category1 ) $category_show = $category1;
            $dataspace['category_show'] =  $category_show;

            $premium = true; //$list->get('premium');
            if ($premium) $dataspace['premium_show'] =  1;

            $denied = $list->get('denied');
            if ($denied) $dataspace['denied_show'] =  'denied';
            else $dataspace['denied_show'] =  'new';

            // print_r($dataspace);
            $list_updated[$player_id] = $dataspace;
        }


        $list_source_updated =& new ArrayDataSet($list_updated);
        $this->Template->setChildDataSource('List', $list_source_updated);

    }

}






?>